package com.ui;


import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.SWT;
import org.eclipse.wb.swt.SWTResourceManager;
import org.eclipse.swt.widgets.Link;

import com.i18n.Messages;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

/**
* @ClassName: AboutIT
* @Description: TODO
* @author alterhu2020@gmail.com
* @date Feb 15, 2014 9:25:40 PM
* 
*/

public class AboutIT extends Dialog {

	protected Object result;
	protected Shell shell_about;

	/**
	 * Create the dialog.
	 * @param parent
	 * @param style
	 */
	public AboutIT(Shell parent) {
		super(parent, SWT.DIALOG_TRIM |SWT.CENTER| SWT.APPLICATION_MODAL);
		//setText("SWT Dialog");
	}

	/**
	 * Open the dialog.
	 * @return the result
	 */
	public Object open() {
		createContents();
		shell_about.open();
		shell_about.layout();
		Display display = getParent().getDisplay();
		org.eclipse.swt.graphics.Rectangle screenSize = display.getPrimaryMonitor().getBounds();
		shell_about.setLocation((screenSize.width - shell_about.getBounds().width) / 2, (screenSize.height - shell_about.getBounds().height) / 2);
		
		Label label_first_version = new Label(shell_about, SWT.NONE);
		label_first_version.setBounds(203, 151, 55, 15);
		label_first_version.setText(Messages.AboutIT_label_first_version_text);
		
		Label lblNewLabel = new Label(shell_about, SWT.NONE);
		lblNewLabel.setBounds(264, 151, 123, 15);
		lblNewLabel.setText(Messages.version_number);
		
		Label label = new Label(shell_about, SWT.NONE);
		label.setBounds(203, 172, 84, 24);
		label.setText(Messages.AboutIT_label_text);
		
		Link link = new Link(shell_about, SWT.NONE);
		link.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				
				org.eclipse.swt.program.Program.launch(e.text);
			}
		});
		link.setBounds(293, 172, 213, 15);
		link.setText(Messages.AboutIT_link_text);
		while (!shell_about.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
		return result;
	}

	/**
	 * Create contents of the dialog.
	 */
	private void createContents() {
		shell_about = new Shell(getParent(), getStyle());
		shell_about.setImage(SWTResourceManager.getImage(AboutIT.class, "/com/images/logo.png"));
		shell_about.setSize(538, 437);
		shell_about.setText("\u5173\u4E8E\u6211\u4EEC");
		
		Label lblNewLabel_logo = new Label(shell_about, SWT.NONE);
		lblNewLabel_logo.setImage(SWTResourceManager.getImage(AboutIT.class, "/com/images/logo.png"));
		lblNewLabel_logo.setBounds(10, 20, 142, 176);
		
		Label label_title = new Label(shell_about, SWT.NONE);
		label_title.setBounds(203, 20, 274, 105);
		label_title.setText(Messages.AboutIT_label_title_text);
		
		Link link_qq = new Link(shell_about, SWT.NONE);
		link_qq.setBounds(203, 201, 158, 21);
		link_qq.setText(Messages.AboutIT_link_qq_text);
		
		Label label_contactus = new Label(shell_about, SWT.NONE);
		label_contactus.setBounds(135, 207, 55, 15);
		label_contactus.setText("\u8054\u7CFB\u6211\uFF1A");
		
		Link link_sina = new Link(shell_about, SWT.NONE);
		link_sina.setBounds(203, 228, 142, 29);
		link_sina.setText("<a>\u65B0\u6D6A\u5FAE\u535A\uFF1AOneOrAlter</a>");
		
		Link link_email = new Link(shell_about, SWT.NONE);
		link_email.setBounds(203, 263, 197, 21);
		link_email.setText(Messages.AboutIT_link_email_text);
		
		Link link_qqqun = new Link(shell_about, SWT.NONE);
		link_qqqun.setBounds(203, 301, 173, 15);
		link_qqqun.setText("<a>QQ\u7FA4\uFF1A347798788</a>");
		
		Label lblNewLabel_ad = new Label(shell_about, SWT.NONE);
		lblNewLabel_ad.setBounds(10, 339, 473, 60);
		lblNewLabel_ad.setText(Messages.AboutIT_lblNewLabel_ad_text);

	}
}
